package com.zy.baselib.widget.popup

import android.content.Context
import android.view.View
import java.lang.ref.SoftReference

/**
 * @author: shalei
 * @since: 2020/12/20 11:34 AM
 * @Desc:
 **/
abstract class BasePopup {

    private lateinit var mSmartPopupWindow: SmartPopupWindow

    abstract fun onCreateView(context: Context): View

    abstract fun onViewCreated(popupWindow: SmartPopupWindow, contentView: View)

    fun create(ctx: Context) {
        val contentView = onCreateView(ctx)
        val mPopupWindow = SmartPopupWindow.Builder
                .build(ctx, contentView)
                .createPopupWindow()
        onViewCreated(mPopupWindow, contentView = contentView)
        mSmartPopupWindow = mPopupWindow
    }

    fun getPopupWindow():SmartPopupWindow {
        return mSmartPopupWindow
    }

}